<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>wk博客</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet"  th:href="@{/css/bootstrap.css}" />
    <link rel="stylesheet" type="text/css" th:href="@{/layui/css/layui.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/css/mian.css}">

    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
    <script type="text/javascript" th:src="@{/layui/layui.js}"></script>
    <script type="text/javascript" th:src="@{/layui/blog.js}"></script>
    <script th:src="@{/js/jquery.js}"></script>
    <script th:src="@{/js/bootstrap.js}"></script>
    <script type="text/javascript" th:src="@{/js/bootstrap-paginator.js}"></script>

</head>
<body class="lay-blog">
<!--菜单-->
<ul class="layui-nav layui-bg-blue" lay-filter="">
    <li class="layui-nav-item "><a th:href="@{/community/index}" style="font-size: 20px">首页</a></li>
<!--    <li class="layui-nav-item">-->
<!--        <a href="javascript:;" style="font-size: 20px">习题库</a>-->
<!--        <dl class="layui-nav-child"> &lt;!&ndash; 二级菜单 &ndash;&gt;-->
<!--            <dd>-->
<!--                <a th:href="@{/item/chapter/overview}">分章节练习</a>-->
<!--            </dd>-->
<!--            <dd>-->
<!--                <a th:href="@{/item/overview}">分题型练习</a>-->
<!--            </dd>-->
<!--        </dl>-->
<!--    </li>-->
<!--    <li class="layui-nav-item">-->
<!--        <a href="javascript:;" style="font-size: 20px">课程分类</a>-->
<!--        <dl class="layui-nav-child"> &lt;!&ndash; 二级菜单 &ndash;&gt;-->
<!--            <dd>-->
<!--                <a th:href="@{'/course/type_show/'+${coursetype.getId()}}" th:each="coursetype:${coursetypes}" th:text="${coursetype.getCourse_name()}"></a>-->
<!--            </dd>-->
<!--            <dd>-->
<!--                <a th:href="@{/course/type_show/0}" >全部课程</a>-->
<!--            </dd>-->
<!--        </dl>-->
<!--    </li>-->
<!--    <li class="layui-nav-item layui-this" th:if="${session.loginuser} == null"><a th:href="@{/community/index}" style="font-size: 20px">社区</a></li>-->
<!--    <li class="layui-nav-item layui-this" th:if="${session.loginuser} != null">-->
<!--        <a href="javascript:;" style="font-size: 20px">社区</a>-->
<!--        <dl class="layui-nav-child">-->
<!--            <dd><a th:href="@{/community/index}">社区首页</a></dd>-->
<!--            <dd><a th:href="@{/stu/community/commenting}">发布话题</a></dd>-->
<!--            <dd><a th:href="@{/stu/community/management}">我的话题</a></dd>-->
<!--            <dd><a th:href="@{/stu/chat_all}" target="_blank">头脑风暴</a></dd>-->
<!--        </dl>-->
<!--    </li>-->
<!--    <li class="layui-nav-item"><a th:href="@{/file/list}" style="font-size: 20px">资料干货</a></li>-->

    <!--如果没有登录-->
    <li class="layui-nav-item" th:if="${session.loginuser} == null">
        <a th:href="@{/login}" style="font-size: 20px">登录</a>
    </li>
    <li class="layui-nav-item" th:if="${session.loginuser} == null">
        <a th:href="@{/register}" style="font-size: 20px">注册</a>
    </li>
    <!--如果没有登录-->

    <!--如果登录-->
    <li class="layui-nav-item" th:if="${session.loginuser} != null">
        <a href="javascript:;" style="font-size: 20px">我的班级</a>
        <dl class="layui-nav-child"> <!-- 二级菜单 -->
            <dd>
                <a th:href="@{/stu/map/show}">班级签到</a>
            </dd>
            <dd>
                <a th:href="@{/stu/exam/overview}">班级考试</a>
            </dd>
            <dd>
                <a th:href="@{/stu/exam/mydegree/list}">我的考试成绩</a>
            </dd>
        </dl>
    </li>
    <li class="layui-nav-item" th:if="${session.loginuser} != null">
        <a href="javascript:;" style="font-size: 20px">好友管理</a>
        <dl class="layui-nav-child"> <!-- 二级菜单 -->
            <dd>
                <a th:href="@{/stu/friends/list}">好友列表</a>
            </dd>
            <dd>
                <a th:href="@{/stu/friends/search}">搜索好友</a>
            </dd>
        </dl>
    </li>
    <li class="layui-nav-item" th:if="${session.loginuser} != null">
        <img th:src="@{'/show/'+${session.loginuser.getId()}}" class="layui-nav-img">[[${session.loginuser.username}]]
        <dl class="layui-nav-child">
            <dd><a th:href="@{/stu/center}">个人中心</a></dd>
            <dd><a th:href="@{/stu/logout}">退出</a></dd>
        </dl>
    </li>

    <!--如果登录-->
</ul>
<!--菜单-->


<!--发布话题-->
<ul class="layui-fixbar">
    <li id="edit" class="layui-icon layui-icon-edit" style="background-color: rgb(0, 150, 136); display: list-item;"></li>
    <li id="go_top" class="layui-icon layui-fixbar-top" lay-type="top" style="background-color: rgb(0, 150, 136); display: list-item;" ></li>
</ul>
<!--发布话题-->

<div class="container-wrap">
    <div class="container">
        <div class="contar-wrap">
            <h4 class="item-title">
                <p><i class="layui-icon layui-icon-speaker"></i>公告：<span>各位同学注意文明用语，营造一个良好的社区学习环境</span></p>
            </h4>
            <h4 class="item-title">
                <!--                搜索框-->
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5" id="formpage" th:action="@{/community/index}">
                        <!--                            保存当前有多少页-->
                        <input type="hidden" th:value="${pageinfo.pageNum}" id="page" name="page">
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="subject" th:value="${subject}" placeholder="请输入话题" autocomplete="off"  class="layui-input">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="username" th:value="${username}" placeholder="请输入用户名" autocomplete="off"  class="layui-input">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn"   type="submit"><i class="layui-icon">&#xe615;</i></button>
                        </div>
                    <span class="layui-breadcrumb">
                      <a ><cite>按时间排序</cite></a>
                      <a th:href="@{/community/index_praise}">按点赞数排序</a>
                    </span>

                    </form>
                </div>
<!--                <button class="layui-btn ">排序</button>-->
                <!--                搜索框-->
            </h4>
            <div class="item" th:each="blog:${pageinfo.list}"  th:praise="${blog.getPraise()}">
                <div class="item-box  layer-photos-demo1 layer-photos-demo">
                    <h2><a th:href="@{'/community/blog/detailed/'+${blog.getId()}}" th:text="${blog.getSubject()}"></a></h2>
                    <h4><span><img class="layui-nav-img" th:src="@{'/show/'+${blog.getUser_id()}}" ></span><a th:href="@{'/stu/chat_one/'+${blog.getUser_id()}}" target="_blank" th:text="${blog.getUsername()}"></a></h4>
                    <h5>发布于：<span th:text="${#dates.format(blog.getCreatetime(),'yyyy年MM月dd日 HH:mm')}"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</h5>
<!--                    <input type="hidden" class="mypraise" th:value="${blog.getPraise()}">-->
<!--                    <p th:text="${blog.getContent()}"></p>-->
<!--                    <img th:src="@{/images/item.png}" alt="">-->
                </div>
                <div class="comment count" >
                    <a th:href="@{'/community/blog/detailed/'+${blog.getId()}}"><i class="layui-icon layui-icon-survey"></i>评论</a>
                    <a href="javascript:;" class="like" th:data="${blog.getId()}"><i class="layui-icon layui-icon-praise"></i><em class="myem123" th:text="${blog.getPraise()}"></em>点赞</a>
                </div>
            </div>
        </div>
        <!--使用bootstrop-paginot实现分页-->
        <div class="text-center">
        <ul id="pagination"></ul>
        </div>
    </div>
</div>


<!--底部-->
<div class="footer">
    <p>
        <span>&copy; 2020</span>
        <span><a href="http://120.78.82.248:8080" target="_blank">计算机网络课程资源共享网</a></span>
        <span>王侃</span>
    </p>
    <p><span>长风破浪会有时，直挂云帆济沧海</span></p>
</div>
<!--底部-->

</body>
<script>

    //分页
    $(function () {
        $('#pagination').bootstrapPaginator({
            bootstrapMajorVersion: 3,
            currentPage:[[${pageinfo.PageNum}]],
            totalPages:[[${pageinfo.Pages}]],
            itemTexts: function (type, page, current) {
                switch (type) {
                    case "first":
                        return "首页";
                    case "prev":
                        return "上一页";
                    case "next":
                        return "下一页";
                    case "last":
                        return "末页";
                    case "page":
                        return page;
                }
            },
            //重新提交，不会因为点击而忽略了查找值
            onPageClicked:function (event,originalEvent,type,page) {
                $('#page').val(page);
                $('#formpage').submit();
            }
            // pageUrl: function (type, page, current) {
            //     return '/stu/community/index?page=' + page ;
            // }
        })
    });

    $(document).ready(function () {
        $('#edit').click(function () {
           location.href='/stu/community/commenting';
        });
        $('#go_top').click(function () {
            $("html,body").animate({"scrollTop":0});
        });

        //点赞功能
        $('.like').click(function () {
            var this_id=$(this).attr('data');
            // $(this).children('em').text(praise2);

            $.post(
                '/stu/community/praise',
                {'id':this_id},
                function (result) {

                }
            );
        })
    })
</script>
</html>